package com.qikecn.utils;

public class SessionUtil {
	
	public static final String KEY_AUTH = "key";
	public static final String KEY_USERID = "userId";
	
	/**
	 * 保存用户到sesstion
	 * @param session
	 * @param key
	 * @param userId
	 * @return
	 */
	/*public static boolean setAttribute(HttpSession session, String key, String userId){
		if(session == null){
			return false;
		}
		session.setAttribute(KEY_AUTH, key);
		session.setAttribute(KEY_USERID, userId);
		return true;
	}
	
	public static String getKey(HttpSession session){
		if(session == null || session.getAttribute(KEY_AUTH) == null){
			return "";
		}
		return session.getAttribute(KEY_AUTH).toString();
	}
	
	public static String getUserId(HttpSession session){
		if(session == null || session.getAttribute(KEY_USERID) == null){
			return "";
		}
		return session.getAttribute(KEY_USERID).toString();
	}
	
	public static boolean isLogin(HttpSession session){
		if(session == null){
			return false;
		}
		if(session.getAttribute(KEY_AUTH) == null){
			return false;
		}
		if(session.getAttribute(KEY_USERID) == null){
			return false;
		}
		return true;
	}*/
	
	/*public static Map<String, String> getAttribute(HttpSession session){
		Map<String, String> map = new HashMap<String, String>();
		if(session == null){
			return map;
		}
		map.put(KEY_AUTH, session.getAttribute(KEY_AUTH).toString());
		map.put(KEY_USERID, session.getAttribute(KEY_USERID).toString());
		return map;
	}*/
	
	
}
